
#include "RtBase.h"
#include "RtAcceptorUdp.h"
#include "RtUtilTemplates.h"
#include "RtUdpEndpoint.h"	

CRtAcceptorUdp::CRtAcceptorUdp()
: m_listenForRudp(FALSE)
{
	m_pEndpointManager = CRtUdpEndpointManager::Instance();
}

CRtAcceptorUdp::~CRtAcceptorUdp()
{
	StopListen(RT_OK);
}

RtResult CRtAcceptorUdp::
StartListen(IRtAcceptorConnectorSink *aSink, const CRtInetAddr &aAddrListen)
{
	RtResult rv = m_pEndpointManager->StartListen(this, aSink, aAddrListen, m_listenForRudp);
	if (RT_FAILED(rv))
		return rv;

	m_AddrLocal = aAddrListen;
	CRtStopFlag::SetStartFlag();
	return RT_OK;
}

RtResult CRtAcceptorUdp::StopListen(RtResult )
{
	if (CRtStopFlag::IsFlagStopped())
		return RT_OK;

	m_pEndpointManager->StopListen(m_AddrLocal);
	CRtStopFlag::SetStopFlag();
	return RT_OK;
}

